package file;

import java.io.File;

public class ListFilesDemo {
    public static void main(String[] args) {
        File dir=new File(".");
        System.out.println("是否为一个文件："+dir.isFile());
        System.out.println("是否为一个目录:"+ dir.isDirectory());
        if (dir.isDirectory()){
            File[] subs=dir.listFiles();
            System.out.println(subs.length);
            for (int i=0;i<subs.length;i++){
                File sub=subs[i];
                System.out.println(sub.getName());
            }
        }
    }
}
